package com.novanok.mailtweets.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.novanok.mailtweets.R;
import com.novanok.mailtweets.entidad.Carpeta;

import java.util.ArrayList;

public class ListaCarpetaAdapter extends BaseAdapter {

    ArrayList<Carpeta> myList = new ArrayList<Carpeta>();
    LayoutInflater inflater;
    Context context;

    public ListaCarpetaAdapter(Context context, ArrayList<Carpeta> myList) {
        this.myList = myList;
        this.context = context;
        inflater = LayoutInflater.from( this.context );
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return myList.size();
    }

    @Override
    public Carpeta getItem(int arg0) {
        // TODO Auto-generated method stub
        return myList.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView( int arg0, View arg1, ViewGroup arg2 ) {
        if ( arg1 == null ) {
            arg1 = inflater.inflate( R.layout.list_item_carpeta, arg2, false );
        }

        TextView nombre = ( TextView )arg1.findViewById( R.id.txtNombreCarpeta );
        TextView descripcion = ( TextView )arg1.findViewById( R.id.txtDescripcionCarpeta );

        synchronized ( myList ) {
            Carpeta msg = myList.get(arg0);

            nombre.setText( "@" + msg.getNombre() );
            descripcion.setText( msg.getDescripcion() );
        }

        return arg1;
    }
}